package com.ylb.rent.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylb.rent.util.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;

import com.ruoyi.common.enums.BusinessType;
import  com.ylb.rent.entity.SchoolApartmentDist;
import com.ylb.rent.service.ISchoolApartmentDistService;



/**
 * 学校公寓Controller
 * 
 * @author ylb
 * @date 2023-06-29
 */
@RestController
@RequestMapping("/apartment/dist")
public class SchoolApartmentDistController
{
    @Autowired
    private ISchoolApartmentDistService schoolApartmentDistService;

    /**
     * 查询学校公寓列表
     */
    @PreAuthorize("@ss.hasPermi('apartment:dist:list')")
    @GetMapping("/list")
    public String list(SchoolApartmentDist schoolApartmentDist)
    {
        ;
        List<SchoolApartmentDist> list = schoolApartmentDistService.selectSchoolApartmentDistList(schoolApartmentDist);
        return R.successJSONData(list);
    }


    /**
     * 获取学校公寓详细信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:dist:query')")
    @GetMapping(value = "/{id}")
    public String getInfo(@PathVariable("id") Long id)
    {
        return R.successJSONData(schoolApartmentDistService.selectSchoolApartmentDistById(id));
    }

    /**
     * 新增学校公寓
     */
    @PreAuthorize("@ss.hasPermi('apartment:dist:add')")
    @Log(title = "学校公寓", businessType = BusinessType.INSERT)
    @PostMapping
    public String add(@RequestBody SchoolApartmentDist schoolApartmentDist)
    {
        return R.successJSONData(schoolApartmentDistService.insertSchoolApartmentDist(schoolApartmentDist));
    }

    /**
     * 修改学校公寓
     */
    @PreAuthorize("@ss.hasPermi('apartment:dist:edit')")
    @Log(title = "学校公寓", businessType = BusinessType.UPDATE)
    @PutMapping
    public String edit(@RequestBody SchoolApartmentDist schoolApartmentDist)
    {
        return R.successJSONData(schoolApartmentDistService.updateSchoolApartmentDist(schoolApartmentDist));
    }

    /**
     * 删除学校公寓
     */
    @PreAuthorize("@ss.hasPermi('apartment:dist:remove')")
    @Log(title = "学校公寓", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public String remove(@PathVariable Long[] ids)
    {
        return R.successJSONData(schoolApartmentDistService.deleteSchoolApartmentDistByIds(ids));
    }
}
